home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / fsmakedev / RCS / fsmakedev.c,v < prev    next >
Text File  |  1990-09-11  |  3KB  |  167 lines

  1. head     1.3;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.3
  10. date     90.09.11.13.49.11;  author jhh;  state Exp;
  11. branches ;
  12. next     1.2;
  13.  
  14. 1.2
  15. date     89.01.11.09.53.22;  author rab;  state Exp;
  16. branches ;
  17. next     1.1;
  18.  
  19. 1.1
  20. date     89.01.11.09.49.33;  author rab;  state Exp;
  21. branches ;
  22. next     ;
  23.  
  24.  
  25. desc
  26. @@
  27.  
  28.  
  29. 1.3
  30. log
  31. @changed -p option to use octal numbers
  32. @
  33. text
  34. @/* 
  35.  * fsmakedev.c --
  36.  *
  37.  *    Make a device file.
  38.  *
  39.  * Copyright (C) 1986 Regents of the University of California
  40.  * All rights reserved.
  41.  */
  42.  
  43. #ifndef lint
  44. static char rcsid[] = "$Header: /a/newcmds/fsmakedev/RCS/fsmakedev.c,v 1.2 89/01/11 09:53:22 rab Exp $ SPRITE (Berkeley)";
  45. #endif not lint
  46.  
  47. #include "sprite.h"
  48. #include "option.h"
  49. #include "fs.h"
  50. #include "kernel/fs.h"
  51. #include "stdio.h"
  52.  
  53. /*
  54.  * Constants settable via the command line.
  55.  */
  56. char *deviceName;        /* Set to "/dev/rsd0" */
  57. char    *permissionString = "0644";
  58. int serverID = -1;
  59. int deviceType = 0;
  60. int deviceUnit = 0;
  61.  
  62. Option optionArray[] = {
  63.     {OPT_STRING, "p", (Address)&permissionString,
  64.     "Permission bits in octal (default is 0644)"},
  65.     {OPT_INT, "s", (Address)&serverID,
  66.     "Server ID, (default is localhost)"},
  67.     {OPT_INT, "d", (Address)&deviceType,
  68.     "Device type, (default is 0)"},
  69.     {OPT_INT, "u", (Address)&deviceUnit,
  70.     "Device unit, (default is 0)"},
  71. };
  72. int numOptions = sizeof(optionArray) / sizeof(Option);
  73.  
  74.  
  75. /*
  76.  *----------------------------------------------------------------------
  77.  *
  78.  * main --
  79.  *
  80.  *    Creates a device file.  Each device has a serverID that
  81.  *    identfies what host has the device, a device type, and
  82.  *    a device unit number.  The serverID is -1 by default,
  83.  *    which means it is a ``generic'' device that is found
  84.  *    on the local host.
  85.  *
  86.  * Results:
  87.  *    None.
  88.  *
  89.  * Side effects:
  90.  *    Calls Fs_MakeDevice.
  91.  *
  92.  *----------------------------------------------------------------------
  93.  */
  94. main(argc, argv)
  95.     int argc;
  96.     char *argv[];
  97. {
  98.     ReturnStatus status;    /* status of system calls */
  99.     int flags = 0;
  100.     Fs_Device device;
  101.     int    permissions;
  102.     int n;
  103.  
  104.     argc = Opt_Parse(argc, argv, optionArray, numOptions, 0);
  105.  
  106.     if (argc < 2) {
  107.     fprintf(stderr, "Specify device file name.\n");
  108.     Opt_PrintUsage(argv[0], optionArray, numOptions);
  109.     exit(FAILURE);
  110.     } else {
  111.     deviceName = argv[1];
  112.     }
  113.     n = sscanf(permissionString, " %o", &permissions);
  114.     if (n != 1) {
  115.     Opt_PrintUsage(argv[0], optionArray, numOptions);
  116.     exit(FAILURE);
  117.     }
  118.     device.serverID = serverID;
  119.     device.type = deviceType;
  120.     device.unit = deviceUnit;
  121.     device.data = (ClientData)0;
  122.     status = Fs_MakeDevice(deviceName, &device, permissions);
  123.     if (status != SUCCESS) {
  124.     fprintf(stderr, "%s \"%s\" <%x,%x,%x>:", argv[0], deviceName,
  125.                   device.serverID, device.type, device.unit);
  126.     Stat_PrintMsg(status, "");
  127.     }
  128.     exit(status);
  129. }
  130. @
  131.  
  132.  
  133. 1.2
  134. log
  135. @reversed arguments to Opt_PrintUsage.
  136. @
  137. text
  138. @d11 1
  139. a11 1
  140. static char rcsid[] = "$Header: /a/newcmds/fsmakedev/RCS/fsmakedev.c,v 1.1 89/01/11 09:49:33 rab Exp Locker: rab $ SPRITE (Berkeley)";
  141. d24 1
  142. a24 1
  143. int permissions = 0644;
  144. d30 2
  145. a31 2
  146.     {OPT_INT, "p", (Address)&permissions,
  147.     "Permission bits (default is 0644)"},
  148. d68 2
  149. d80 5
  150. a84 1
  151.  
  152. @
  153.  
  154.  
  155. 1.1
  156. log
  157. @Initial revision
  158. @
  159. text
  160. @d11 1
  161. a11 1
  162. static char rcsid[] = "$Header: makeDevice.c,v 1.2 87/06/19 16:30:53 andrew Exp $ SPRITE (Berkeley)";
  163. d73 1
  164. a73 1
  165.     Opt_PrintUsage(argv[0], numOptions, optionArray);
  166. @
  167.